'use strict';

let xs = ['0-0-0','0-0-1','0-1-1','1-1-1','1-1-2','1-2-2','2-2-2'];
let ys = ['000','001','011','111','112','122','222'];

let matrixNumber;
let x;
let y;
let txIndex = 0;

module.exports.createMatrix = async function (bc, workerIndex, args) {

    while (txIndex < args.assets) {
        txIndex++;
        matrixNumber = 'client' + workerIndex + '_Matrix' + txIndex.toString();
        x = xs[Math.floor(Math.random()*xs.length)];
        y = ys[Math.floor(Math.random()*ys.length)];

        const Args = {
            contractId: 'credit-evaluation',
            contractVersion: 'v1.0',
            contractFunction: 'CreateMatrix',
            invokerIdentity: 'Admin',
            contractArguments: [matrixNumber, x, y],
            timeout: 30
        };

        await bc.sendRequests(Args);
    }

};
